/*
 * @Author: viivLgr 
 * @Date: 2018-05-31 16:33:42 
 * @Last Modified by: viivLgr
 * @Last Modified time: 2018-06-04 16:37:34
 */
import Util from 'util/util.jsx';

const _util = new Util();

class User {
    // 用户登录
    login(data) {
        return _util.request({
            url: '/manage/user/login.do',
            type: 'POST',
            data: data
        });
    }
    // 检查登录接口的数据是不是合法
    checkLoginInfo(data) {
        let username = $.trim(data.username),
            password = $.trim(data.password);
        // 判断用户名为空
        if (typeof username !== 'string' || username.length === 0) {
            return {
                status: false,
                msg: '用户名不能为空'
            }
        }
        // 判断密码为空
        if (typeof password !== 'string' || password.length === 0) {
            return {
                status: false,
                msg: '密码不能为空'
            }
        }
        return {
            status: true,
            msg: '验证通过'
        }
    }
    // 退出登录
    logout() {
        return _util.request({
            url: '/user/logout.do',
            type: 'POST'
        });
    }
    getUserList(pageNum) {
        return _util.request({
            url: '/manage/user/list.do',
            data: {
                pageNum: pageNum
            }
        });
    }
}

export default User;